mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	Add C sample (#3698)
* Add C sample Sample was incorrectly being identified as C++ * Changed asm.h license to the Unlicense * Changed asm.h license to Apache 2.0
This commit is contained in:
		
				
					committed by
					
						 Colin Seymour
						Colin Seymour
					
				
			
			
				
	
			
			
			
						parent
						
							d5c8db3fb9
						
					
				
				
					commit
					c552e25bd7
				
			
							
								
								
									
										27
									
								
								samples/C/asm.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								samples/C/asm.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,27 @@ | ||||
| /* CarbonOS System/Kernel | ||||
|  * Copyright 2015-2017 David Aylaian | ||||
|  * Licensed under Apache 2.0: https://github.com/DavidAylaian/CarbonOS/blob/master/LICENSE.md | ||||
|  */ | ||||
|  | ||||
| #ifndef ASM_H | ||||
| #define ASM_H | ||||
|  | ||||
| #include <stdint.h> | ||||
|  | ||||
| // macros for enabling and disabling interrupts | ||||
| #define enable()	asm("sti"); | ||||
| #define disable()	asm("cli"); | ||||
|  | ||||
| // inb instruction | ||||
| uint8_t inb (uint16_t port) { | ||||
| 	uint8_t val; | ||||
| 	asm volatile ("inb %0, %1" : "=a"(val): "Nd"(port)); | ||||
| 	return val; | ||||
| } | ||||
|  | ||||
| // outb instruction | ||||
| void outb (uint16_t port, uint8_t val) { | ||||
| 	asm volatile ("outb %1, %0" : : "a"(val), "Nd"(port)); | ||||
| } | ||||
|  | ||||
| #endif | ||||
		Reference in New Issue
	
	Block a user